package com.wehealth.adapter;

import java.util.List;

import com.wehealth.R;
import com.wehealth.dm.DM_PlanDay;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class Adapter_PlanDay extends BaseAdapter {

	/**
	 * 上下文
	 */
	private Context ctx;
	/**
	 * 列表数据
	 */
	private List<DM_PlanDay> theList;
	
	public Adapter_PlanDay(Context ctx,List<DM_PlanDay> theList){
		this.ctx = ctx;
		this.theList = theList;
	}

	@Override
	public int getCount() {
		return theList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		
		View view = LayoutInflater.from(ctx).inflate(R.layout.plan_day_list_item,null);
		int state = theList.get(arg0).getState();
		Log.d("SIMMON","state="+state);
		if(state == 0){
			view.setBackgroundResource(R.drawable.playday_cellitem_bg);
		}else{
			view.setBackgroundResource(R.drawable.playday_cellitem_bg_tag);	
		}
		TextView time = (TextView)view.findViewById(R.id.planDay_item_time);
		
		TextView content = (TextView)view.findViewById(R.id.planDay_item_content);
		time.setText(theList.get(arg0).getTime());
		
		content.setText(theList.get(arg0).getPlanContent());
		
//		ViewHolder holder = null;
//		if (convertView == null) {
//			holder = new ViewHolder();
//			//转化控件
//			//SIMMON_ADD
//			convertView = LayoutInflater.from(ctx).inflate(R.layout.plan_day_list_item,null);
//			//id
//			//holder.id = (TextView)convertView.findViewById(R.id.planItem_ID);
//			//名称
//			holder.time = (TextView)convertView.findViewById(R.id.planDay_item_time);
//			
//			holder.content = (TextView)convertView.findViewById(R.id.planDay_item_content);
//			
//
//
//			convertView.setTag(holder);
//		}else {
//			holder = (ViewHolder) convertView.getTag();
//		}
		//赋值
		//holder.id.setText(theList.get(arg0).getID()+"");
//		holder.time.setText(theList.get(arg0).getTime());
//		
//		holder.content.setText(theList.get(arg0).getPlanContent());
		
		//holder.post.setText(dr_list.get(arg0).getLevel());
		//holder.desc.setText(dr_list.get(arg0).getIntro());
		
		
		return view;
	}
//	// adapter所需字段
//	public final class ViewHolder {
//		public TextView id;
//		// 
//		public TextView time;
//		
//		public TextView content;
//		
//		
//	}
}